/* Copyright (c) 2010 OFXKit
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#import <Foundation/Foundation.h>
#import "OFXObject.h"

/**
 * @class OFXCurrency
 * 
 * In each transaction involving amounts, responses include a default currency 
 * identification, <CURDEF>. The values are based on the ISO-4217 three-letter 
 * currency identifiers.
 * 
 * Within each transaction, specific parts of the response might need to report
 * a different currency. Where appropriate, aggregates include an optional 
 * <CURRENCY> aggregate. The scope of a <CURRENCY> aggregate is everything 
 * within the same aggregate that the <CURRENCY> aggregate appears in, 
 * including nested aggregates, unless overridden by a nested <CURRENCY> 
 * aggregate. For example, specifying a <CURRENCY> aggregate in an investment 
 * statement detail means that the unit price, transaction total, commission, 
 * and all other amounts are in terms of the given currency, not the default 
 * currency.
 * 
 * Note that there is no way for two or more individual elements that represent
 * amounts—and are directly part of the same aggregate—to have different 
 * currencies. For example, there is no way in a statement download to have a 
 * different currency for the <LEDGERBAL> and the <AVAILBAL>, because they are 
 * both directly members of <STMTRS>. In most cases, you can use the optional 
 * <BAL> aggregates to overcome this limitation, since <BAL> aggregates accept 
 * individual <CURRENCY> aggregates.
 * 
 * The default currency for a request is the currency of the source account. 
 * For example, the currency for <BANKACCTFROM>.
 * 
 * The <CURRATE> should be the one in effect throughout the scope of the 
 * <CURRENCY> aggregate. It is not necessarily the current rate. Note that the 
 * <CURRATE> needs to take into account the choice of the FI for formatting of 
 * amounts (that is, where the decimal is) in both default and overriding 
 * currency, so that a client can do math. This can mean that the rate is 
 * adjusted by orders of magnitude (up or down) from what is commonly reported 
 * in newspapers.
 * 
 * In some cases, OFX defines transaction responses so that amounts have been 
 * converted to the home currency. However, OFX allows FIs to optionally report
 * the original amount and the original (foreign) currency. In these cases, 
 * transactions include a specific aggregate for the original amount, and then 
 * an <ORIGCURRENCY> aggregate to report the details of the foreign currency.
 * 
 * NOTE: The above excerpt was taken from the OFX 2.1 specification
 */
@interface OFXCurrency : OFXObject {
  NSNumber* exchangeRate;
  NSString* currencySymbol;
  NSString* originalCurrencySymbol;
}

/**
 * @property exchangeRate
 * @brief Ratio of <CURDEF> currency to <CURSYM> currency, in decimal notation, 
 * rate
 */
@property(retain) NSNumber* exchangeRate;

/**
 * @property currencySymbol
 * @brief A three-letter code that identifies the currency used for a request 
 * or response. The currency codes are based on ISO-4217.
 */
@property(retain) NSString* currencySymbol;

/**
 * @property originalCurrencySymbol
 * @brief A three-letter code that identifies the original currency used as a 
 * reference for the exchange rate. The currency codes are based on ISO-4217.
 */
@property(retain) NSString* originalCurrencySymbol;

@end
